package com.seraph.zys.web.system;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.seraph.bi.suite.support.security.BaseUser;
import com.seraph.bi.suite.support.security.LoginUtil;
import com.seraph.bi.suite.support.web.json.JsonProviderController;
import com.seraph.zys.service.tree.OrgTreeManager;
import com.seraph.zys.service.tree.OrgTreeNode;
@Controller
@RequestMapping("/reportUnLockTree.do")
public class ReportUnLockTreeController extends JsonProviderController{
	
	@Autowired
	OrgTreeManager orgTreeManager=null;
	
	public void setOrgTreeManager(OrgTreeManager orgTreeManager) {
		this.orgTreeManager = orgTreeManager;
	}


	@Override
	protected Object handleJsonRequest(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		Object obj=null;
		String id=request.getParameter("node"); 
		if(id!=null){
			if(id.trim().equals("root")){
				BaseUser user = (BaseUser) LoginUtil.getUser();
				String orgCode = user.getOrgCode();
				obj=orgTreeManager.getTreeNodeByOrgCode(orgCode);
			}else{
				obj=orgTreeManager.getTreeNodeListByParentId(id);
			}
		}
		return obj;
	}
	
}
